<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            border: 1px solid #000;
        }

        .red {
            background-color: #f00;
        }

        .op {
            opacity: .5;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click=" isRed = !isRed ">切换</button>

        <!-- 可以写死一些类，然后可以再动态绑定一些类 -->
        <!-- 他们不冲突,可以同时使用 -->
        <!-- 如果有多个动态类,那么逗号隔开 -->
        <div class="box" :class="{ red: isRed, op: true }">我是div</div>
    </div>

    <script src="./vue.js"></script>

    <script>
        new Vue({
            el: '#app',
            data: {
                isRed: false
            }
        })
    </script>
</body>
</html>